import sqlite3
import os
# 获取当前文件的绝对路径
current_file_path = os.path.abspath(__file__)
print("当前文件的路径是:", current_file_path)
# 获取当前文件所在的目录
current_directory = os.path.dirname(current_file_path)
print("当前文件的目录是:", current_directory)

file_path = os.path.join(current_directory, 'history.sqlite3')

# 创建数据库连接
conn = sqlite3.connect('history.db')
c = conn.cursor()

# 创建历史记录表
c.execute('''CREATE TABLE IF NOT EXISTS history
             (id INTEGER PRIMARY KEY AUTOINCREMENT,
             question TEXT,
             answer TEXT)'''
)
question="你是谁"
answer="我是小智"
c.execute("INSERT INTO history (question, answer) VALUES (?, ?)", (question, answer))
conn.commit()
    
c.close()
conn.close()